package de.tabuma.wsdl2xform.xform.view;

import de.tabuma.lib.tabumaview;
import de.tabuma.wsdl2xform.xform.*;
import java.io.*;
import java.util.*;
import java.util.logging.*;
import javax.servlet.*;
import javax.servlet.http.*;

/**
 *
 * @author alefen
 */
public class projectPage2 extends tabumaview {

    private static Logger log = Logger.getLogger(projectPage2.class.getName());

    public projectPage2(String servlet, Hashtable parameter) {
        super(servlet, parameter);
    }

    public void processRequest(ServletContext context, HttpServletRequest request, HttpServletResponse response, PrintWriter out) {

        try {

            List<String> messageList = (List<String>)request.getAttribute(constants.METHOD_LIST);

            out.println("<form action=\""+de.tabuma.wsdl2xform.controller.constants.SERVLET_NAME+"\">");
            out.println("<input type=\"hidden\" name=\""+de.tabuma.wsdl2xform.controller.constants.MAINNAV+"\" value=\""+de.tabuma.wsdl2xform.controller.constants.NAVID_CREATEXFORM+"\"/>");
            out.println("<input type=\"hidden\" name=\""+constants.XFORM_NAV+"\" value=\""+constants.NAV_SECOND_STEP+"\"/>");
            out.println("<input type=\"hidden\" name=\""+constants.NAV_NEXT_STEP+"\" value=\"true\"/>");

            out.println("<input type=\"hidden\" name=\""+constants.PROJECT_NAME+"\" value=\""+request.getAttribute(constants.PROJECT_NAME)+"\"/>");
            out.println("<input type=\"hidden\" name=\""+constants.PROJECT_DESCRIPTION+"\" value=\""+request.getAttribute(constants.PROJECT_DESCRIPTION)+"\"/>");
            out.println("<input type=\"hidden\" name=\""+constants.WSDL_URL+"\" value=\""+request.getAttribute(constants.WSDL_URL)+"\"/>");
            out.println("<input type=\"hidden\" name=\""+constants.T_DEFINITIONS_KEY+"\" value=\""+request.getAttribute(constants.T_DEFINITIONS_KEY)+"\"/>");

            //Data from step1
            out.println("<div class=\"contentHeader\">"+constants.getValue("xform.header")+"</div>");
            out.println("<div class=\"contentContent\">");

            out.println("<p class=\"contentContentHeader\">"+constants.getValue("xform.step2")+"</p>");

            //Step 2
            out.println("WSDL Method");
            out.println("<select name=\""+constants.PROJECT_METHOD+"\">");
            Iterator<String> messageIterator = messageList.iterator();
            while(messageIterator.hasNext()) {
                String message = messageIterator.next();
                out.println("<option value=\""+message+"\">"+message+"</option>");
            }
            out.println("</select>");
            out.println("<br/>");
            out.println("<input type=\"submit\" name=\"submit\" value=\"Next Step\" class=\"loginbutton\"/>");
            out.println("</div>");

            out.println("</form>");

        }
        catch(Exception e) {
            log.warning(e.getMessage());
        }
    }

}
